/*
 * Copyright 2020-2021 redragon.dongbin
 *
 * This file is part of redragon-erp/赤龙ERP.

 * redragon-erp/赤龙ERP is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.

 * redragon-erp/赤龙ERP is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with redragon-erp/赤龙ERP.  If not, see <https://www.gnu.org/licenses/>.
 */
package com.erp.ledger.je.dao.hibernate;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Repository;
import org.redragon.framework.annotation.Cache;
import org.redragon.framework.annotation.Permissions;
import org.redragon.framework.annotation.Permissions.PermissionType;
import org.redragon.framework.annotation.SqlParam;
import org.redragon.framework.hibernate.DaoSupport;
import org.redragon.framework.hibernate.model.Pages;
import org.redragon.framework.util.DaoCRUDUtil;

import com.erp.ledger.je.dao.GLJeModelHeadDao;
import com.erp.ledger.je.dao.model.GLJeModelHead;
import com.erp.ledger.je.dao.model.GLJeModelHeadCO;

@Repository
public class GLJeModelHeadDaoImpl implements GLJeModelHeadDao{ 

    //注入DaoSupport工具类
    @Autowired
    private DaoSupport daoSupport;
    
    @Override
    public void insertDataObject(GLJeModelHead obj) {
        this.daoSupport.insertDataTransaction(obj);
    }

    @Override
    public void updateDataObject(GLJeModelHead obj) {
        this.daoSupport.updateDataTransaction(obj);
    }
    
    @Override
    public void insertOrUpdateDataObject(GLJeModelHead obj) {
        this.daoSupport.insertOrUpdateDataTransaction(obj);
    }

    @Override
    public void deleteDataObject(GLJeModelHead obj) {
        this.daoSupport.deleteDataTransactionJPA(obj);
    }

    @Override
    public List<GLJeModelHead> getDataObjects() {
        return this.daoSupport.getDataAllObject(GLJeModelHead.class);
    }

    @Override
    public GLJeModelHead getDataObject(int id) {
        return (GLJeModelHead)this.daoSupport.getDataObject(GLJeModelHead.class, id);
    }
    
    @Override
    public GLJeModelHead getDataObject(String code) {
        return null;
    }
    
    @Override
    public List<GLJeModelHead> getDataObjects(GLJeModelHeadCO paramObj) {
        return null;
    }
    
    @Override
    public List<GLJeModelHead> getDataObjects(Pages pages) {
        return null;
    }
    
    @Override
    public List<GLJeModelHead> getDataObjects(Pages pages, GLJeModelHeadCO paramObj) {
        String sql = "select v.* from gl_je_model_head v where 1=1";
        
        Map<String, Object> args = new HashMap<String, Object>();
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "jeHeadCode", "and v.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "jeName", "and v.", args);
        sql = sql + DaoCRUDUtil.getSQLSearch(paramObj, "status", "and v.", args);
        sql = sql + " order by v.je_head_id desc";
        
        this.daoSupport.validateDataObject(paramObj);
        
        Map<String, Class<?>> entity = new HashMap<String, Class<?>>();
        entity.put("v", GLJeModelHead.class);
        
        return this.daoSupport.getDataSqlByPage(sql, entity, args, pages);
    }

    @Override
    public List<Map<String, Object>> getDataObjectsArray(Pages pages, GLJeModelHeadCO paramObj) {
        return null;
    }
    
    @Override
    @Permissions(PermissionType.DATA_AUTH)
    public List<GLJeModelHead> getDataObjectsForDataAuth(@SqlParam String dataAuthSQL, Pages pages, GLJeModelHeadCO paramObj) {
        return null;
    }
    
}
